import 'dart:io';
import 'dart:ui';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:oktoast/oktoast.dart';
import 'package:super_tool_server/business/drag_util.dart';
import 'package:super_tool_server/business/log_manager.dart';
import 'package:super_tool_server/common/utils/log.dart';
import 'package:super_tool_server/component/navigator/navigator.dart';
import 'package:super_tool_server/page/page_route.dart';
import 'package:super_tool_server/resource/r.dart';

class MainAppUI extends StatefulWidget {
  MainAppUI({Key? key}) : super(key: key) {
    PageManager.customRouteDelegate.pushPage(name: PageManager.page_home);
  }

  @override
  State<MainAppUI> createState() => _MainAppUIState();
}

class _MainAppUIState extends State<MainAppUI> {
  @override
  void initState() {
    super.initState();
    init();
  }

  @override
  void dispose() {
    super.dispose();
  }

  Future<void> init() async {

  }

  @override
  void draggingFileEntered() {
    addLog("文件拖动开始...", color: Colors.green);
  }

  @override
  void draggingFileExit() {
    addLog("文件拖动结束...", color: Colors.yellow);
  }

  void addLog(String log, {Color color = const Color(0xAFFFFFFF)}) {
    if (mounted) {
      LogManager.getInstance().addLog(log, color: color);
    }
  }

  @override
  void prepareForDragFileOperation() {
    addLog("准备处理拖动的文件...", color: Colors.green);
    // superLog.info("flutter: prepareForDragFileOperation");
  }


  @override
  Widget build(BuildContext context) {
    return Container(
        color: Color(0xFF2C2C2C),
        child: OKToast(
          child: MaterialApp.router(
            title: 'SuperCube',
            debugShowCheckedModeBanner: false,
            theme: ThemeData(
                textTheme: Theme.of(context).textTheme,
                platform: TargetPlatform.iOS,
                primaryColor: Colors.white,
                // accentColor: Color(0xff302B34),
                splashColor: Colors.transparent),
            routeInformationParser: CustomRouteParser(),
            routerDelegate: PageManager.customRouteDelegate,
          ),
        ));
  }
}
